import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import './index.css'
import App from './App.tsx'
import MainLayout from './layouts/MainLayout.tsx'
import AuthLayout from './layouts/AuthLayout.tsx' // 新增的AuthLayout
import Home from './pages/Home.tsx'
import About from './pages/About.tsx'
import Services from './pages/Services.tsx'
import Cases from './pages/Cases.tsx'
import News from './pages/News.tsx'
import Contact from './pages/Contact.tsx'
import Search from './pages/Search.tsx'
import EnglishHome from './pages/English/Home.tsx'
import EnglishAbout from './pages/English/About.tsx'
import EnglishServices from './pages/English/Services.tsx'
import EnglishCases from './pages/English/Cases.tsx'
import EnglishNews from './pages/English/News.tsx'
import EnglishContact from './pages/English/Contact.tsx'
import EnglishSearch from './pages/English/Search.tsx'
import AdminLogin from './pages/Admin/Login.tsx' // 新增的中控登录页面
import AdminDashboard from './pages/Admin/Dashboard.tsx' // 新增的中控操作台页面

const router = createBrowserRouter([
  {
    element: <App />,
    children: [
      // 主站点路由，使用MainLayout
      {
        element: <MainLayout />,
        children: [
          { index: true, element: <Home /> },
          { path: 'about', element: <About /> },
          { path: 'services', element: <Services /> },
          { path: 'cases', element: <Cases /> },
          { path: 'news', element: <News /> },
          { path: 'search', element: <Search /> },
          { path: 'contact', element: <Contact /> },
          
          // 英文版路由，路径前加/en
          { path: 'en', element: <EnglishHome /> },
          { path: 'en/about', element: <EnglishAbout /> },
          { path: 'en/services', element: <EnglishServices /> },
          { path: 'en/cases', element: <EnglishCases /> },
          { path: 'en/news', element: <EnglishNews /> },
          { path: 'en/search', element: <EnglishSearch /> },
          { path: 'en/contact', element: <EnglishContact /> },
        ]
      },
      // 中控系统路由，使用AuthLayout
      {
        element: <AuthLayout />,
        children: [
          { path: 'admin/login', element: <AdminLogin /> },
          { path: 'admin/dashboard', element: <AdminDashboard /> },
        ]
      }
    ]
  }
])

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <RouterProvider router={router} />
  </StrictMode>,
)